//
//  KASlider.swift
//  kano
//
//  Created by Frank on 2025/6/9.
//

import Foundation
import UIKit

class KASlider: UISlider {
    var customThumbSize = CGSize(width: 22, height: 22)
    
    override func thumbRect(forBounds bounds: CGRect,
                           trackRect rect: CGRect,
                           value: Float) -> CGRect {
        let defaultRect = super.thumbRect(forBounds: bounds,
                                        trackRect: rect,
                                        value: value)
        
        // 计算新位置保持滑块中心不变
        let x = defaultRect.origin.x + (defaultRect.width - customThumbSize.width) / 2
        let y = defaultRect.origin.y + (defaultRect.height - customThumbSize.height) / 2
        
        return CGRect(x: x,
                     y: y,
                     width: customThumbSize.width,
                     height: customThumbSize.height)
    }
}
